/**
 * Server.java
 *
 * Created on 13-mar-2010, 19.16.53
 * 
 * @author Beatrice Bacelli
 * @author Luca Bedogni
 * @author Silvia Righini
 */

package unibo.lsb.graphic;

import java.awt.Dimension;
import java.awt.event.ActionEvent;

import javax.swing.JFrame;

/**
 *
 */
public class ServerWindow extends javax.swing.JFrame {

	/** Creates new form Server */
	public ServerWindow() {
		initComponents();
	}

	ServerWindow(JFrame jFrame) {
		initComponents();
	}

	private void initComponents() {

		setSize(new Dimension(550, 370));
		setLocationRelativeTo(null);
		setTitle("Server Log");

		scrollPane = new javax.swing.JScrollPane();
		txa_Server = new javax.swing.JTextArea();
		btn_Terminate = new javax.swing.JButton();

		setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

		txa_Server.setColumns(20);
		txa_Server.setRows(5);
		txa_Server.setEnabled(false);
		scrollPane.setViewportView(txa_Server);

		btn_Terminate.setText("Terminate Server");
		btn_Terminate.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				btn_terminateBtnPressed(evt);
			}
		});

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
				getContentPane());
		getContentPane().setLayout(layout);
		layout
				.setHorizontalGroup(layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								layout
										.createSequentialGroup()
										.addGroup(
												layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addGroup(
																layout
																		.createSequentialGroup()
																		.addContainerGap()
																		.addComponent(
																				scrollPane,
																				javax.swing.GroupLayout.PREFERRED_SIZE,
																				519,
																				javax.swing.GroupLayout.PREFERRED_SIZE))
														.addGroup(
																layout
																		.createSequentialGroup()
																		// .add(205,
																		// 205,
																		// 205)
																		.addComponent(
																				btn_Terminate)))
										.addContainerGap(
												javax.swing.GroupLayout.DEFAULT_SIZE,
												Short.MAX_VALUE)));
		layout
				.setVerticalGroup(layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								layout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(
												scrollPane,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												290,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(btn_Terminate)
										.addContainerGap(
												javax.swing.GroupLayout.DEFAULT_SIZE,
												Short.MAX_VALUE)));
	}// </editor-fold>//GEN-END:initComponents

	protected void btn_terminateBtnPressed(ActionEvent evt) {
		System.exit(0);
	}

	/**
	 * @param args
	 *            the command line arguments
	 */
	public static void main(String args[]) {
		java.awt.EventQueue.invokeLater(new Runnable() {
			public void run() {
				new ServerWindow().setVisible(true);
			}
		});
	}

	public boolean addText(String text) {
		txa_Server.setText(txa_Server.getText() + text + "\n");
		return true;
	}

	private javax.swing.JButton btn_Terminate;
	private javax.swing.JScrollPane scrollPane;
	private javax.swing.JTextArea txa_Server;

}